package controller

import (
	"github.com/kataras/iris"
	"github.com/kataras/iris/sessions"

	"im/model"
	"im/requests"
	"im/responses"
	"im/service"
)

type PrivateMessagesController struct {
	Base
	Session *sessions.Session
	Ctx     iris.Context
}

// swagger:route GET /private_messages/{friendId} friends get-private_messages
//
// 获取私聊聊天记录
//
// 获取私聊的聊天记录
//
//   Deprecated: true
//   Security:
//   - jwt_key:
//   Responses:
//     200:GetPosts
func (c *PrivateMessagesController) Get(friendId int64) {
	var (
		user     = c.Ctx.Values().Get("user").(model.Users)
		resp = responses.GetPrivateMessages{}
		// param
		param = requests.GetMessages{}
		err error
	)
	_ = c.Ctx.ReadQuery(&param)
	resp, err = service.NewMessagesService().GetList(uint(user.Id), int64(friendId), param)
	if err!=nil{
		c.SendCry(err)
		return
	}
	c.SendSmile(resp)
}
